package com.explorati.design_pattern.hybrid.strategyfactory;

//自由消费策略
public class FreeDeduction implements IDeduction {

	@Override
	public boolean exec(Card card, Trade trade) {
		// 获取交易金额
		double m = trade.getAmount();
		// 获取卡中的自由金额
		double f = card.getFreeMoney();
		// 如果交易金额大于自由金额，交易失败
		if (m > f) {
			return false;
		} else {
			card.setFreeMoney(f - m);
			return true;
		}
	}

}
